/**
 * A single Contact represents a person's contact information:
 * - A StreetAddress containing a street address
 * - A Name (first, last)
 * - An Email address
 * - A PhoneNum containing a phone number
 * - Notes, to store additional information
 * @author Joshua Zeiser
 *
 * Implements Comparable to allow comparison of Contact objects
 */
import java.util.*;
import java.io.*;

public class Contact implements Comparable<Contact>, Serializable{
	
	private StreetAddress streetAddress;
	private Name name;
	private Notes notes;
	private EMail eMail;
	private PhoneNum phoneNum;
	
	/**
	 * Constructor that takes all arguments to initialize
	 * @param name
	 * @param notes
	 * @param email
	 * @param phoneNum
	 * @param streetAddress
	 */
	public Contact(Name name, Notes notes, EMail email, PhoneNum phoneNum, StreetAddress streetAddress) {
		this.name = name;
		this.notes = notes;
		this.eMail = email;
		this.phoneNum = phoneNum;
		this.streetAddress = streetAddress;
	}
	
	/**
	 * empty constructor for Contact
	 */
	public Contact() {

	}
	
	/**
	 * Implements toString() method, returns entire Contact as a String
	 * @author JZ, MS
	 */
	@Override
	public String toString()
	{
		// TODO implement full toString() method
		String contactString = "\n" + this.name +
				"\n" + this.streetAddress +
				"\n" + this.eMail +
				"\n" + this.phoneNum +
				"\n" + this.notes +
				"\n";
		return contactString;
	}	
	
	/**
	 * Takes a StreetAddress object, sets this to given values
	 * @param s
	 */
	public void setStreetAddress(StreetAddress s) {
		this.streetAddress = s;
	}
	
	/**
	 * Takes a Name object, sets this to given value
	 * @param n
	 */
	public void setName(Name n) {
		this.name = n;
		
	}
	
	/**
	 * Takes a Notes object, sets this to given values
	 * @param n
	 */
	public void setNotes(Notes n) {
		this.notes = n;
	}
	
	/**
	 * Takes an EMail object, sets this to given values
	 * @param e
	 */
	public void setEMail(EMail e){
		this.eMail = e;
	}
	
	/**
	 * Takes a PhoneNum object, sets this to given values
	 * @param p
	 */
	public void setPhoneNum(PhoneNum p){
		this.phoneNum  = p;
	}
	
	/**
	 * Get the StreetAddress object
	 * @return this.streetAddress
	 */
	public StreetAddress getStreetAddress() {
		return this.streetAddress;
	}
	
	/**
	 * Returns this Name object
	 * @return this.name
	 */
	public Name getName() {
		return this.name;
	}
	
	/**
	 * Returns this Notes object
	 * @return this.notes
	 */
	public Notes getNotes() {
		return this.notes;
	}
	
	/**
	 * Returns this EMail object
	 * @return this.eMail
	 */
	public EMail getEMail() {
		return this.eMail;
	}
	
	/**
	 * Returns this PhoneNum object
	 * @return this.phoneNum
	 */
	public PhoneNum getPhoneNum() {
		return this.phoneNum;
	}
	

	/**
	 * Implements compareTo for a Contact
	 * Compares by Name because Names are comparable
	 * @param c
	 * @return int
	 */
	@Override public int compareTo(Contact c) {
		
		// unlikely, but just in case the two Contacts are the same
		if(this == c) {
			return 0;
		}
		
		//compares the Name objects of each Contact
		//may need to add additional testing if the Names are equal
		return this.name.compareTo(c.getName());
	}
	
	/**
	 * Implements and overrides default Object equals functionality
	 * Allows equality test of Contact objects
	 * @param c
	 * @return boolean
	 */
	@Override public boolean equals(Object c) {
		if(this == c) return true;
		if(!(c instanceof Contact)) return false;
		
		Contact c2 = (Contact)c;
		
		return (this.name.equals(c2.getName()));
	}
}
	
